//
//  RNOLAccountSecurityViewController.m
//  RongNiuOnline
//
//  Created by apple on 2018/4/11.
//  Copyright © 2018年 rongniu. All rights reserved.
//

#import "RNOLAccountSecurityViewController.h"
#import "RNOLUpdatePayPasswordViewController.h"
#import "RNOLLoginDeviceManagerViewController.h"
#import "RNOLPaySettingsViewController.h"

@interface RNOLAccountSecurityViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) NSDictionary *dataDict;

@end


@implementation RNOLAccountSecurityViewController

- (UITableView *)tableView{
    if(!_tableView){
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KWIDTH , KHIGHT) style:UITableViewStyleGrouped];
        _tableView.backgroundColor = kBgColor;
        adjustsScrollViewInsets_NO(_tableView, self);
//        _tableView.height -= kBottomHeight;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KWIDTH , 10)];
        header.backgroundColor = kBgColor;
        _tableView.tableHeaderView = header;
        _tableView.tableFooterView = [UIView new];
        [self.view addSubview: _tableView];
    }
    return _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNavBarTitleViewWithText:@"账号与安全"];
    [self setup];
}

- (void)setup{
    self.dataDict = @{
                       @"0" : @[@"账户ID"],
                       @"1" : @[@"登录密码",@"交易密码"],
                       @"2" : @[@"刷脸设置",@"支付设置"],
                       @"3" : @[@"登录设备管理",@"绑定手机号码"],
                       @"4" : @[@"检测更新",@"我的客服"]
                      };
    [self.tableView reloadData];
    
    
}

#pragma mark -  UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [self.dataDict.allKeys count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSArray *items = self.dataDict[@(section).stringValue];
    return items.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    [self configCellDataWithIndexPath: indexPath cell: cell];
    return cell;
}

//设置cell
- (void)configCellDataWithIndexPath:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell {
    NSArray *items = self.dataDict[@(indexPath.section).stringValue];
    cell.textLabel.text = items[indexPath.row] ;
    
    if (indexPath.section == 0 && indexPath.row == 0) {
        cell.detailTextLabel.text = @"融牛在线666";
    }else if (indexPath.section == 3 && indexPath.row == 1 ){
        cell.detailTextLabel.text = @"130xxxx6294";
    }else if (indexPath.section == 4 && indexPath.row == 0 ){
        cell.detailTextLabel.text = @"v1.0.0";
        cell.detailTextLabel.textColor = kAssistRedColor ;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KWIDTH , 10)];
    footer.backgroundColor = kBgColor;
    return footer;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 5;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 10;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSArray *items = self.dataDict[@(indexPath.section).stringValue];
    NSString *title = [items objectAtIndex: indexPath.row];

    if ([title isEqualToString:@"账户ID"]) {
        
    }else if ([title isEqualToString:@"登录密码"]){
        
    }else if ([title isEqualToString:@"交易密码"]){
        RNOLUpdatePayPasswordViewController *updateVC = [[RNOLUpdatePayPasswordViewController alloc] init];
        [self.navigationController pushViewController: updateVC animated:YES];
        
    }else if ([title isEqualToString:@"刷脸设置"]){
        
        
    }else if ([title isEqualToString:@"支付设置"]){
        [self pushPageWithClass:[RNOLPaySettingsViewController class]];
    }else if ([title isEqualToString:@"登录设备管理"]){
        [self pushPageWithClass:[RNOLLoginDeviceManagerViewController class]];
    }else if ([title isEqualToString:@"绑定手机号码"]){
        
        
    }else if ([title isEqualToString:@"检测更新"]){
        
        
    }else if ([title isEqualToString:@"我的客服"]){
        
        
    }

}



@end
